package org.wxy.test.test2;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;
public class Main
{
    public static void main(String[] args)
    {
        Scanner sc=new Scanner(System.in);
        int n1;
        n1=sc.nextInt();
        sc.nextLine();
        ArrayList<PersonOverride> po=new ArrayList<PersonOverride>();
        int i;
        for(i=0;i<n1;i++)
        {
            po.add(new PersonOverride());
        }
        int n2;
        n2=sc.nextInt();
        sc.nextLine();
        for(i=0;i<n2;i++)
        {
            boolean f=true;
            PersonOverride a=new PersonOverride(sc.next(),sc.nextInt(),sc.nextBoolean());
            sc.nextLine();
            for(PersonOverride ap:po)
            {
                if(ap.equals(a))
                {
                    f=false;
                    break;
                }
            }
            if(f)
            {
                po.add(a);
            }
        }
        for(PersonOverride s:po)
        {
            System.out.println(s.toString());
        }
        System.out.println(po.size()-n1);
        System.out.println(Arrays.toString(PersonOverride.class.getConstructors()));
    }
}
class PersonOverride
{
    private String name;
    protected int age;
    private boolean gender;
    public PersonOverride()
    {
        this("default",1,true);
    }
    public PersonOverride(String name,int age,boolean gender)
    {
        this.name=name;
        this.age=age;
        this.gender=gender;
    }
    public String toString()
    {
        return name + "-" + age + "-" + gender;
    }
    public boolean equals(Object o)
    {
        if(o==null)
        {
            return false;
        }
        else
        {
            boolean result=false;
            if(o instanceof PersonOverride)
            {
                PersonOverride rec=(PersonOverride) o;
                if(this.gender==rec.gender&&this.age==rec.age&&this.name==rec.name)
                {
                    return true;
                }
            }
            return result;
        }
    }
}
